import request from '@/utils/request'

const api_name = '/admin/system/sysRole'

export default {
  findAll() {
    return request({
      url: `${api_name}/findAll`,
      method: 'get'
    })
  },

  // 分页查询
  getPageList(current, limit, searchObj) {
    return request({
      url: `${api_name}/${current}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 删除角色
  removeById(id) {
    return request({
      url: `${api_name}/remove/${id}`,
      method: 'delete'
    })
  },
  // 添加角色
  save(sysRole) {
    return request({
      url: `${api_name}/save`,
      method: 'post',
      data: sysRole
    })
  },
  // 获得角色
  getById(id) {
    return request({
      url: `${api_name}/get/${id}`,
      method: 'get'
    })
  },
  // 更新角色
  updateById(sysRole) {
    return request({
      url: `${api_name}/update`,
      method: 'put',
      data: sysRole
    })
  },
  // 批量删除
  batchRemove(idList) {
    return request({
      url: `${api_name}/batchRemove`,
      method: 'delete',
      data: idList
    })
  },
  // 获得角色
  getRoles(adminId) {
    return request({
      url: `${api_name}/toAssign/${adminId}`,
      method: 'get'
    })
  },
  // 分配角色
  assignRoles(assginRoleVo) {
    return request({
      url: `${api_name}/doAssign`,
      method: 'post',
      data: assginRoleVo
    })
  }
}
